package com.group.controller;

import com.base.view.GeneralResult;
import com.base.view.ListResult;
import com.group.dao.LeaderBoardDao;
import com.group.model.Out.LeaderBoardOut;
import com.group.service.LeaderBoardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/leaderBoard")
public class LeaderboardController extends BaseController{

    @Autowired
    LeaderBoardService leaderBoardService;

    @Autowired
    LeaderBoardDao leaderBoardDao;

    /**
     * 获取用户收益排行榜
     * @return
     */
    @RequestMapping(value = "/getUBLB", method = { RequestMethod.GET })
    public ListResult<LeaderBoardOut> getUBLB(){
        List<LeaderBoardOut> list = leaderBoardService.getUBLB();
        return new ListResult<LeaderBoardOut>().setList(list).setTotal(100);
    }

    /**
     * 获取财富排行榜
     * @return
     */
    @RequestMapping(value = "/getWealth", method = { RequestMethod.GET })
    public ListResult<LeaderBoardOut> getWealth(){
        List<LeaderBoardOut> list = leaderBoardService.getWealth();
        return new ListResult<LeaderBoardOut>().setList(list).setTotal(100);
    }

    /**
     * 获取中奖排行榜
     * @return
     */
    @RequestMapping(value = "/getWinning", method = {RequestMethod.GET})
    public ListResult<LeaderBoardOut> getWinning(){
        List<LeaderBoardOut> list = leaderBoardDao.queryWinning();
        return new ListResult<LeaderBoardOut>().setList(list).setTotal(100);
    }

    @RequestMapping(value = "/getMyWinning", method = {RequestMethod.GET})
    public GeneralResult getMyWinning(Long userId){
        Map<String,Object> ret = leaderBoardService.getMyWinning(userId);
        return new GeneralResult().setValue(ret);
    }

    /**
     * 获取返佣排行榜
     * @return
     */
    @RequestMapping(value = "/getRebate", method = {RequestMethod.GET})
    public ListResult<LeaderBoardOut> getRebate(){
        List<LeaderBoardOut> list = leaderBoardDao.queryRebate();
        return new ListResult<LeaderBoardOut>().setList(list).setTotal(100);
    }

    /**
     * 返佣排行榜中，我的排名
     * @return
     */
    @RequestMapping(value = "/getMyRebate", method = {RequestMethod.GET})
    public GeneralResult getMyRebate(Long userId){
        Map<String,Object> ret = leaderBoardService.getMyRebate(userId);
        return new GeneralResult().setValue(ret);
    }

    /**
     * 收益排行中，我的排名
     * @param userId
     * @return
     */
    @RequestMapping(value = "/getMyUBLB", method = {RequestMethod.GET})
    public GeneralResult getMyUBLB(Long userId){
        Map<String,Object> ret = leaderBoardService.getMyUBLB(userId);
        return new GeneralResult<Map>().setValue(ret);
    }

    /**
     * 财富排行中，我的排名
     * @param userId
     * @return
     */
    @RequestMapping(value = "/getMyWealth", method = {RequestMethod.GET})
    public GeneralResult getMyWealth(Long userId){
        Map<String,Object> ret = leaderBoardService.getMyWealth(userId);
        return new GeneralResult<Map>().setValue(ret);
    }
}
